//alert("hello world!")



var  xiaoming ={

    name:"王小明",
    age:12,
}


var laowang={

    name:"王建国",
    age:40,
}

xiaoming.dad=laowang;

var n = laowang.age-xiaoming.age;
//alert(n);

var dom = document.createElement("h2");
document.body.appendChild(dom);
dom.innerHTML= "小标题";

var dom2 = document.getElementById("dabiaoti");
dom2.style.color = "red";

dom2.remove();

var qiuhe = function () {

    var shuru1 = document.getElementById("shuru1");
    var jiashu1 = Number(shuru1.value);

    var shuru2 = document.getElementById("shuru2");
    var jiashu2 = Number(shuru2.value);

    var  he =jiashu1+jiashu2;

    var dom = document.getElementById("jieguo");
    dom.innerHTML = he;
}

var add = function (a,b) {

    var c = a+b;
    return c;
}

var  res = add(3,2);
//alert(res);


var dom = document.createElement("h1");
document.body.appendChild(dom);

var n= 12+Number('34');
n+=10;
dom.innerHTML=n;



var duanzi = "下课铃响了,老师:\" 最后我还要讲一点......\"\n 小明:\"强扭的瓜不甜。\" \n 老师:\" 小明你留下,其他瓜下课!\" ";

duanzi = duanzi.replace(/\n/g,'<br>');

var dom = document.createElement('p');
dom.innerHTML = duanzi[0];
dom.innerHTML = duanzi.substr(0,5);
dom.innerHTML = duanzi.indexOf('小明');
document.body.appendChild(dom);



var arr = [0,1,2,3,4,5];

var dom1 = document.createElement("h1");
dom1.innerHTML = '数组长度'+arr.length;
document.body.appendChild(dom1);

var dom2 = document.createElement('h1');
dom2.innerHTML = '2号元素是'+arr[2];
document.body.appendChild(dom2);

var dom3 = document.createElement('h1');
dom3.innerHTML = '截取的是'+arr.slice(1,4);
document.body.appendChild(dom3);

arr.splice(2,2);
var dom4 = document.createElement("h1");
dom4.innerHTML = '删除后'+arr;
document.body.appendChild(dom4);

arr.splice(2,0,2,3);
var dom5 = document.createElement("h1");
dom5.innerHTML = '插入后'+arr;
document.body.appendChild(dom5);


var n = arr.indexOf(3);
var m = arr.indexOf(9);
var dom6 = document.createElement("h1");
dom6.innerHTML = '搜索结果'+n+'和'+m;
document.body.appendChild(dom6);


var str = "0;1;2;3;4";
var arr2 = str.split(';');

var dom7 = document.createElement('h1');
dom7.innerHTML='字符串数组长度'+arr2.length;
document.body.appendChild(dom7);


var yuan = document.getElementById('yuan');

var qiehuan = function () {

    var clr = yuan.style.background;
    if(clr=='red'){
        yuan.style.background='green';
    }else if(clr=='green'){

        yuan.style.background ='red';
    }
}

var total = 0;

for(var i=0;i<20;i++){

    console.log(i);
}


var qipao;

var kaishihanshu = function () {

    qipao = new Date();
    var rongqi = document.getElementById('liebiao');

    rongqi.innerHTML = "";
}


var jicihanshu = function () {

    var now = new Date();
    var cha = now-qipao;

    var dom = document.createElement('h4');
    dom.innerHTML=(cha/1000).toFixed(2);

    var rongqi = document.getElementById('liebiao');
    rongqi.appendChild(dom)
}


var n = setInterval(function () {

    var dom = document.getElementById('deng');
    var clr = dom.style.background;
    if(clr=='red'){
        dom.style.background='green';
    }else{

        dom.style.background ='red';
    }
},3000);


for(var i=0;i<50;i++){

    var dom = document.createElement('div');
    var size = Math.floor(Math.random()*200);
    dom.style.width = size+'px';
    dom.style.height = size+'px';

    dom.style.position ='absolute';
    dom.style.left=Math.random()*100+'%';
    dom.style.top=Math.random()*100+'%';
    dom.style['border-radius']='100px';

    var red = Math.floor(Math.random()*256);
    var green = Math.floor(Math.random()*256);
    var blue = Math.floor(Math.random()*256);
    var alpha = Math.random()*0.3;

    var clr = 'rgba('+red+','+green+','+blue+','+alpha+')';
    dom.style.background = clr;
    document.body.appendChild(dom);
}


var jo1 = $('<h1>hello world!</h1>');
var jo2 = $('<h1>hello pie!</h1>');

$('body').append(jo1);
$('body').prepend(jo2);


var jo3 = $('<input value="hello" />');
$('body').append(jo3);

var str2 = jo2.html()+'!!';
jo2.html(str2);

var str3 = jo3.val()+' world!';
jo3.val(str3);


var jo=$('#dom');

var stylestr = jo.attr('style');

var cssstr = jo.css('border');


jo.html(stylestr+'<br>'+cssstr);

jo.css('border','5px solid #FF0');
jo.css({
    'width':'200px',
    'border-radius':'15px',
})

var wid = jo.width();
jo.css('height',wid+'px');
jo.addClass('redfont');
jo.addClass('bigfont');
jo.addClass('graybg');

var classstr = jo.attr('class');
var classarr = classstr.split(' ');
jo.html(classarr[0]);
jo.removeClass(classarr[1]);









































